<?php

/*** begin our session ***/
session_start();

/*** set a form token ***/
$form_token = md5( uniqid('auth', true) );

/*** set the session form token ***/
$_SESSION['FORM_TOKEN'] = $form_token;
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Pablo Arroyo">
    <link rel="shortcut icon" href="images/ico/favicon.ico">

    <title>Pagos 1.0</title>
    
    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <!-- Custom styles for this template -->
    <link href="signin.css" rel="stylesheet">    

  </head>

  <body>

    <div class="container">

        <form class="form-signin" role="form" action="login.php" method="POST">
        <h2 class="form-signin-heading">Inicio de Sesi&oacute;n</h2>
        
        <input type="text" class="form-control"  name="username" id="username" placeholder="Usuario" required autofocus>
        <br>
        <input type="password" class="form-control" name="password" id="password" placeholder="Constrase&ntilde;a" required>
        <input type="hidden" name="form_token" value="<?php echo $_SESSION['FORM_TOKEN']; ?>" />        
        <?php
          if ((isset($_SESSION['LOGIN_ERROR'])) && ($_SESSION['LOGIN_ERROR'] == "ERROR"))
          {
            unset($_SESSION['LOGIN_ERROR']);
          
            print '<div class="alert alert-danger"><strong>Usuario o contrase&ntilde;a incorrecto</strong></div>';
            
            session_write_close();
            
          }
        ?>
        
        <button id="btnLogin" class="btn btn-lg btn-primary btn-block" type="submit">Loguearse</button>
      </form>
      
    </div> <!-- /container -->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="dist/js/jquery-1.11.0.min.js"></script>
    <script src="js/appIndex.js"></script>
  </body>
</html>